package shiyefactory;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘国水
 * Date: 2025-03-30
 * Time: 16:12
 */
public class ProxyUser {
    private User realUser;

    private ProxyUser(User user) {
        this.realUser = user;
    }

    public void menu() {
        this.realUser.menu();
    }

    public void borrowBook(String bookName) {
        System.out.println("检查用户权限");
        if(this.realUser instanceof NormalUser) {
            ((NormalUser) this.realUser).borrowBook(bookName);
        } else {
            System.out.println("您没有权限借阅书籍");
        }

        if(this.realUser instanceof AdminUser) {
            ((AdminUser) this.realUser).addBook(bookName);
        } else{
            System.out.println("您没有权限上架书籍");
        }
    }
}
